import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { LoginComponent } from './login/login.component';
import { IndexComponent } from './index/index.component';
import { LoginGuard } from './login/login.guard';
import { DefaultComponent } from './index/default/default.component';
import { MoniterComponent } from './index/moniter/moniter.component';
import { EnergyQueryComponent } from './index/moniter/energy-query/energy-query.component';
import { DataQueryComponent } from './index/moniter/data-query/data-query.component';
import { Code404Component } from './code404/code404.component';
import { HarmonicQueryComponent } from './index/moniter/harmonic-query/harmonic-query.component';
import { IndicateQueryComponent } from './index/moniter/indicate-query/indicate-query.component';
import { RateComponent } from 'app/index/moniter/rate/rate.component';

// path 是路径, component是路由的组件
const routes: Routes = [
    {
        path: 'login',
        component: LoginComponent,
        children: [],
    },
    {
        path: 'index',
        component: IndexComponent,
        children: [
            {
                path: 'default',
                component: DefaultComponent,
            },
            {
                path: 'moniter',
                component: MoniterComponent,
                children: [
                    {
                        path: '',
                        component: EnergyQueryComponent
                    },
                    {
                        path: 'data-query',
                        component: DataQueryComponent
                    },
                    {
                        path: 'harmonic-query',
                        component: HarmonicQueryComponent
                    },
                    {
                        path: 'indicate-query',
                        component: IndicateQueryComponent
                    },
                    {
                        path: 'indicate-query',
                        component: IndicateQueryComponent
                    }
                ]
            },
            {
                path: 'event',
                component: MoniterComponent,
                children: [
                    {
                        path: '',
                        component: EnergyQueryComponent
                    },
                    {
                        path: 'data-query',
                        component: DataQueryComponent
                    },
                    {
                        path: 'harmonic-query',
                        component: HarmonicQueryComponent
                    },
                    {
                        path: 'indicate-query',
                        component: IndicateQueryComponent
                    },
                    {
                        path: 'indicate-query',
                        component: IndicateQueryComponent
                    }
                ]
            },
            {
                path: 'config',
                component: MoniterComponent,
                children: [
                    {
                        path: '',
                        component: RateComponent
                    },
                    {
                        path: 'device-config',
                        component: DataQueryComponent
                    },
                    {
                        path: 'harmonic-query',
                        component: HarmonicQueryComponent
                    },
                    {
                        path: 'indicate-query',
                        component: IndicateQueryComponent
                    },
                    {
                        path: 'indicate-query',
                        component: IndicateQueryComponent
                    }
                ]
            }
        ],
        canActivate: [LoginGuard]
    },
    {
        path: '',
        redirectTo: '/login',
        pathMatch: 'full'
    },
    {
        path: '**',
        component: Code404Component,
        children: [ ]
    }

];

@NgModule({
    imports: [RouterModule. forRoot(routes)],
    exports: [RouterModule],
    providers: [LoginGuard]
})

export class AppRoutingModule { };
